package com.baor.service.impl;

import com.baor.dao.AddressDao;
import com.baor.service.AddressService;
import com.baor.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    private AddressDao addressDao;
    @Override
    public AjaxResult<?> list(Map<String, Object> params) {
        params.put("pageIndex", (int)params.get("pageSize") * ((int)(params.get("pageIndex")) - 1));
        params.put("pageSize", params.get("pageSize"));
        Map<String,Object> res = new HashMap<>();
        res.put("AdressList", addressDao.list(params));
        res.put("pageCount", addressDao.pageCount(params));
        return AjaxResult.success(res);
    }

    @Override
    public AjaxResult<?> add(Map<String, Object> params) {
        return AjaxResult.success(addressDao.add(params));
    }


    @Override
    public AjaxResult<?> delete(Map<String, Object> params) {
        return AjaxResult.success(addressDao.delete(params));
    }

    @Override
    public AjaxResult<?> update(Map<String, Object> params) {
        return AjaxResult.success(this.addressDao.update(params));
    }

    @Override
    public AjaxResult<?> selectById(Map<String, Object> params) {
        return AjaxResult.success(this.addressDao.selectById(params));
    }


}
